Get Key From value in dictionary

30

myDict={"name":"PythonForBeginners","acronym":"PFB"}
print("Dictionary is:")
print(myDict)
dict_items=myDict.items()
print("Given value is:")
myValue="PFB"
print(myValue)
print("Associated Key is:")
for key,value in dict_items:
    if value==myValue:
        print(key)
# creating a new dictionary
my_dict ={"Java":100, "Python":112, "C":11}
 
# one-liner
print("One line Code Key value: ", list(my_dict.keys())
      [list(my_dict.values()).index(100)])

Comments

Submit
0 Comments